package com.talkweb.yingu.apimodel.admin;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by qsf on 2019/4/3.
 */
@Setter
@Getter
public class SysResourceVo implements Serializable {
    private static final long serialVersionUID=1L;

    /**主键*/
    @ApiModelProperty(value="主键")
    private Long id;
    /**RESOURE_NAME*/
    @ApiModelProperty(value="RESOURE_NAME")
    private String resourceName;
    /**RESOURE_TYPE*/
    @ApiModelProperty(value="RESOURE_TYPE")
    private String resourceType;
    /**RESOURE_URL*/
    @ApiModelProperty(value="RESOURE_URL")
    private String resourceUrl;
    /**PERMISSION*/
    @ApiModelProperty(value="PERMISSION")
    private String permission;
    /**PARENT_ID*/
    @ApiModelProperty(value="PARENT_ID")
    private String parentId;
    /**PARENT_IDS*/
    @ApiModelProperty(value="PARENT_IDS")
    private String parentIds;
    /**APP_ID*/
    @ApiModelProperty(value="APP_ID")
    private Long appId;
    /**VALIDATE_STATE*/
    @ApiModelProperty(value="VALIDATE_STATE")
    private String validateState;
    /**VERSION*/
    @ApiModelProperty(value="VERSION")
    private Long version;

    public static List<TreeNodeVo> toTreeModel(List<SysResourceVo> list) {
        List<TreeNodeVo> treelist = new ArrayList<>();
        for (SysResourceVo vo:list) {
            TreeNodeVo treenode=new TreeNodeVo();
            treenode.setId(vo.getId().toString());
            treenode.setName(vo.getResourceName());
            treenode.setParentId(vo.getParentId());
            treelist.add(treenode);
        }
        return TreeNodeVo.treeBuild(treelist);
    }
}
